package assets_withdraw

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"
	"gitee.com/liuxuezhan/ar-platform/rpc-client/assetsClient/rpc"
	"github.com/jinzhu/copier"
	"github.com/zeromicro/go-zero/core/logx"
)

type AssetsWithDrawTypeFindLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// b端提现管理--提现配置--查询
func NewAssetsWithDrawTypeFindLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AssetsWithDrawTypeFindLogic {
	return &AssetsWithDrawTypeFindLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *AssetsWithDrawTypeFindLogic) AssetsWithDrawTypeFind(req *types.AssetsWithDrawTypeFindReq) (resp *types.AssetsWithDrawTypeFindRes, err error) {
	rpc_req := &rpc.GetWithDrawTypeRequest{
		Name: req.Type,
	}

	// 发送请求
	rpc_resp, err := l.svcCtx.AssetsRpc.PayWithdraw.WithdrawTypeList(l.ctx, rpc_req)
	if err != nil {
		return nil, err
	}

	// 处理请求返回的结果
	// 解析、组合数据
	resp = &types.AssetsWithDrawTypeFindRes{}
	copier.Copy(resp, rpc_resp)
	// for _, d := range rpc_resp.Data {
	// 	resp.Data = append(resp.Data, &types.WithDrawType{
	// 		Type:            d.Type,
	// 		SelectedIcon:   d.SelectedIcon,
	// 		UnselectedIcon: d.UnselectedIcon,
	// 		MinAmount:      d.MinAmount,
	// 		MaxAmount:      d.MaxAmount,
	// 		FeeRate:        d.FeeRate,
	// 		WithdrawTime:   d.WithdrawTime,
	// 		Status:          d.Status,
	// 		Sort:            d.Sort,
	// 		Id:              (d.ID),
	// 	})
	// }
	return
}
